<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<link href="joju.css" rel="stylesheet" type="text/css" />

<link href="../css/idelta.css"/>
<link href="../css/tabbed_panel.css"/>
<link href="../css/application.css"/>
<script type="text/javascript" src="../js/ajax-basics.js"/>
<script type="text/javascript" src="/js/ajax-basics.js"/>
<script type="text/javascript" src="../js/dojo/dojo.js"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>


<script type="text/javascript">
	var djConfig = { isDebug: false };
</script>
<script type="text/javascript" src="../js/dojo/dojo.js">/*_*/</script>


<script type="text/javascript">
/* Initial Nodes */
var treeDat = {
	treeNodes: [
		{ title:"Customer" }
	]
};
</script>

<script type="text/javascript">
/* Initial Nodes */

 function titleClicked(event){
	  var e=window.event;
	  var text = event.srcElement.innerText;
	  text = text.substring(text.indexOf(':')+1);	 
		   var temp = new Array();
		   temp = text.split('|');
		   var url = "../DojoDemoServlet?CustomerID="+escape(temp[1]);
		   sendRequest(url);
  }


 function onNodeClick(event){
			var e=window.event;
			var text = event.srcElement.innerText;
			text = text.substring(text.indexOf(':')+1);	 
		   var temp = new Array();
		   temp = text.split('|');
		   alert("onNodeClick");
		   var url = "../CustomerServlet?CustomerAccountID="+escape(temp[1]);
		   sendRequest(url);
  }



</script>



<script type="text/javascript">
dojo.addOnLoad(function(){
	dojo.require("dojo.lang.*");
	dojo.require("dojo.widget.Tree");
	dojo.require("dojo.widget.TreeNode");
	dojo.require("dojo.widget.TreeRPCController");
	

var TreeBuilder = {
	buildTreeNodes:function (dataObjs, treeParentNode){
		for(var i=0; i<dataObjs.length;i++){
			var node =  dojo.widget.createWidget("TreeNode",{
				title:dataObjs[i].title,
				isFolder: true,
				widgetId:(((treeParentNode)?treeParentNode.widgetId:"root_")+"_"+i)
			});
			treeParentNode.addChild(node);
			treeParentNode.registerChild(node,i);
		}
	},
	buildTree:function (){
		var myTreeWidget = dojo.widget.createWidget("Tree",{
			widgetId:"myTreeWidget",
			expandIconSrcPlus:"../images/package_obj.gif", 
			 expandIconSrcMinus:"../images/package_obj.gif", 
			 iconWidth:13, 
			 iconHeight:13 


		});
		this.buildTreeNodes(treeDat.treeNodes,myTreeWidget);
		var treeContainer = document.getElementById("myWidgetContainer");
		var placeHolder = document.getElementById("treePlaceHolder");
		treeContainer.replaceChild(myTreeWidget.domNode,placeHolder);
	}
}

TreeBuilder.buildTree();
	var myRpcController = dojo.widget.createWidget("TreeRPCController",{
			widgetId:"treeController",
			RPCUrl:"../DojoDemoServlet"
		});
dojo.event.topic.subscribe("nodeSelected",
			 function(message) { alert(message.node.title+" selected"); });

	myRpcController.onTreeClick = function(message){
		var node = message.source;
		var widget = dojo.widget.getWidgetById('treeController');
		var txt = new String(node);
		if(txt.indexOf("|") !=-1)
				{
						var mySplitResult = txt.split("|");
						if ((mySplitResult.length>1) ||
						   (mySplitResult[1].value==null)) {
							widget.RPCUrl = "../DojoDemoServlet?CustomerID="+txt; 
						   }
						   else { 
								widget.RPCUrl = "../DojoDemoServlet?CustomerID="+txt;
							}

							
				}

		else
		{
		widget.RPCUrl = "../DojoDemoServlet?CustomerID=0";
		}
		if (node.isExpanded){
			this.expand(node);
		} else {
			this.collapse(node);
		}

	}



	myRpcController.onTitleClick = function(message){
		var node = message.source;
		var text = node.objectId;
		widget.RPCUrl = "../DojoDemoServlet?CustomerID="+text;
		if (node.isExpanded){
			this.expand(node);
		} else {
			this.collapse(node);
		}

	}

	var treeContainer = document.getElementById("myWidgetContainer");
	treeContainer.appendChild(myRpcController.domNode);
	myRpcController.listenTree(dojo.widget.manager.getWidgetById("myTreeWidget"));
	});
</script>

</head>

</head>


<body>
<table border="0" cellspacing="0" cellpadding="0" usemap="#Map">
  <tr>
  <td>


  <div id="myWidgetContainer"
                   style="width:239; height:557px; overflow-x:auto;overflow-y:auto;">
	
	
<logic:notEqual name="RecordCount" value="0">

	<span id="treePlaceHolder"
		
		Loading Customertree ...
	</span>
</logic:notEqual>

<logic:equal name="RecordCount" value="0">

<span id="UserInforslt">Search criteria Customer does not exist</span>

</logic:equal>

	</div>


	</td>

  </tr>
</table>


<map name="Map" id="Map"><area shape="rect" coords="117,195,213,217" href="tree_main.jsp" target="treemainFrame" />
</map></body>
</html>
